//-----------------------------------------------------------------------------
// Name: DisplayManager.h
// Auth: Dante Ratto, Robert Darty, & Paul Godfrey
// Desc: contains all of the interface required to manipulate the view as well
// as any additional state information.
//-----------------------------------------------------------------------------

#ifndef _DISPLAYMANAGER_
#define _DISPLAYMANAGER_

#include "Bounding.h"

#include <vector>
#include "corona/corona.h"

//-----------------------------------------------------------------------------
// Type Definitions:
//-----------------------------------------------------------------------------
typedef float tVector3f[3];

//-----------------------------------------------------------------------------
// Constants:
//-----------------------------------------------------------------------------
const int kInitialWindowWidth = 800;
const int kInitialWindowHeight = 600;

const tVector3f kUpVector = {0.0f, 1.9f, 0.0f};

//Enum to deal with keyboard movement
enum eMoveMode
{
	kStartMoveRight,
	kStartMoveLeft,
	kStopMoveRight,
	kStopMoveLeft,

	kStartMoveForward,
	kStartMoveBackward,
	kStopMoveForward,
	kStopMoveBackward,
};

//-----------------------------------------------------------------------------
// cDisplayManager:
//-----------------------------------------------------------------------------
class cDisplayManager
{
public:
	// Constructers:
	cDisplayManager();
	~cDisplayManager();

	// DisplayManager:
	cDisplayManager* GetDisplayManager();
	void SetWindowArea(int width, int height);
	int GetWindowWidth();
	int GetWindowHeight();
	void DrawVertWarningBar(int hpos, int vpos);
	void DrawHorzWarningBar(int hpos, int vpos);
	void SetDamageDirection(int);
	int GetDamageDirection();

	//-----------------------------------------------------------------------------
	void SetPerspectiveMode();
	void SetOrthographicMode();
	void UpdateProjection();
	// Desc: controls how the world's projection matrix is created and updated.

	//-----------------------------------------------------------------------------
	void SetCameraPitch(float pitch);
	void SetCameraHeading(float heading);
	void SetCameraOffset(float offset);
	void Move(eMoveMode mode);
	float GetCameraPitch();
	float GetCameraHeading();
	float GetCameraOffset();

	int GetHealth();
	void SetHealth(int);

	float GetCameraX();
	float GetCameraY();
	float GetCameraZ();
	float GetDirection1();
	float GetDirection2();
	float GetDirection3();
	// Desc: allows for basic polar camera manipulation

	//-----------------------------------------------------------------------------
	void UpdateCamera(float elapsedTimeS);
	// Desc: Updates the Camera's movement, takes in time passed per frame

	//-----------------------------------------------------------------------------
	void DrawHUD(float elapsedTimeS);
	// Desc: Draws to the Heads up Display

	//-----------------------------------------------------------------------------
	void SetInitBullets(int);
	// Desc: Sets init bullets for hud

	//-----------------------------------------------------------------------------
	void SetBullets(int);
	// Desc: Updates bullets for hud

	//-----------------------------------------------------------------------------
	int GetBullets();
	// Desc: Gets bullet count

	//-----------------------------------------------------------------------------
	void Reload(float elapsedTimeS);
	// Desc: Reloads gun

	//-----------------------------------------------------------------------------
	void FireDelay(float elapsedTimeS);
	// Desc: Puts delay on firing 

	//-----------------------------------------------------------------------------
	void SetPoints(int);
	// Desc: Updates points

	//-----------------------------------------------------------------------------
	int GetPoints();
	// Desc: Returns points

	//-----------------------------------------------------------------------------
	void SetFireRate(int);
	// Desc: Sets fire rate

	//-----------------------------------------------------------------------------
	int GetFireRate();
	// Desc: Gets fire rate

	//-----------------------------------------------------------------------------
	void SetDead(int);
	// Sets user dead

	//-----------------------------------------------------------------------------
	int GetDead();
	// Gets user dead
	
	//-----------------------------------------------------------------------------
	void SetCameraX(float);
	void SetCameraZ(float);
	// Desc: Set Camera X and Z

	//-----------------------------------------------------------------------------
	float GetFSpeed();
	float GetSSpeed();
	// Desc: Gets Forward and strafe speeds

	//-----------------------------------------------------------------------------
	bool GetStatus();
	void SetStatus(bool);
	// Desc: Gets and sets status

	//-----------------------------------------------------------------------------
	void SetupBulletImage();
	// Desc: Inits the bullet image

	//-----------------------------------------------------------------------------
	void AddBody(float, float, float, float);
	void UpdateBody(float, float, float, float, int);
	// Desc Adds and updates bounding bodies

	//-----------------------------------------------------------------------------
	std::vector<cBounding>* GetBoundingBody();
	cBounding* GetBoundingMaster();
	// Desc: Returns bounding bodies and master sphere

	//-----------------------------------------------------------------------------
	bool GetVictory();
	void SetVictory(bool);
	// Desc: Gets and Sets Victory status

private:
	// Members:
	int mWindowWidth;
	int mWindowHeight;
	int mDamageDirection;
	int mDead;

	bool mVictory;

	enum eProjectionMode
	{
		kOrthographic,
		kPerspective,
	};
	
	eProjectionMode mProjectionMode;
	
	corona::Image* mBulletIconData;
	
	// Camera Variables:
	tVector3f mCameraPosition; 
	tVector3f mCameraVelocity; 
	tVector3f mDirection;
	
	float mCameraPitch;
	float mCameraHeading;
	float mCameraOffset;
	float mStrafeSpeed;
	float mForwardSpeed;
	float mAcceleration;
	float mHeadingAcceleration;
	float mHeadingVelocity;

	int mBullets;
	int mHealth;
	int mPoints;
	int mFireRate;

	bool mStatus;

	std::vector<cBounding> mBody;
	
	cBounding mMaster;
};

#endif